package com.xiyue.leaspring;

import java.lang.reflect.Method;
import java.util.Date;

import org.springframework.expression.EvaluationContext;
import org.springframework.expression.Expression;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;

public class SpELFirstDemo18 {

	public static void main(String[] args) throws Exception {
		// TODO Auto-generated method stub
		String str = "time";//Date类中的getTime方法
		ExpressionParser parser = new SpelExpressionParser();
		Expression exp = parser.parseExpression(str);//设置一个自定义的根变量
		EvaluationContext context = new StandardEvaluationContext(new Date());//根变量赋值
		Long result = exp.getValue(context,Long.class);
		System.out.println(result);
	}

}
